import exceptions.CreatingProcessException;
import implementation1.app.ProcessCreator;
import implementation1.gui.Message;
import interfaces.app.IProcess;

import javax.swing.*;
import java.util.ResourceBundle;

/**
 * Created: 6.10.11
 *
 * @author Jenda Kolena, jendakolena@gmail.com
 * @version 0.1
 */
public class Main
{
    /**
     * Main method. Sets bundles, look and feel. Creates and starts init process.
     *
     * @param args
     */
    public static void main(String[] args)
    {
        ResourceBundle bundle = ResourceBundle.getBundle("implementation1.res.messages");

        try
        {
            for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels())
            {
                if ("Nimbus".equals(info.getName()))
                {
                    UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (Exception e)
        {
            Message.showError(bundle.getString("error.CannotSetLookAndFeel"));
        }

        try
        {
            IProcess initProcess = new ProcessCreator().createRootProcess();
            initProcess.startProcess();
        } catch (CreatingProcessException e)
        {
            Message.showError(bundle.getString("error.ErrorWhileCreatingProcess"));
            System.exit(1);
        }
    }
}
